//
// SoapTrace.Net - A soap message monitoring utility. 
//
// Copyright (C) 2005 Matthew Ward
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// Matthew Ward (mrward@users.sourceforge.net)


using NUnit.Framework;
using SoapTrace.Core.Formatters;
using System;
using System.Drawing;

namespace SoapTrace.Tests.TextFormatting
{
	/// <summary>
	/// Tests the retrieval of text colour from a single piece of text.
	/// </summary>
	[ TestFixture ]
	public class GetTextColourTwoItemsTestFixture
	{
		FormattedText FormattedText;
		string Text1 = "Foo";
		string Text2 = "Bar";
		Color Text1Colour = Color.Red;
		Color Text2Colour = Color.Blue;
		
		/// <summary>
		/// Initialises each test.
		/// </summary>
		[ SetUp ]
		public void Init( )
		{			
			FormattedText = new FormattedText( Text1Colour );
			FormattedText.Append( Text1 );
			FormattedText.Append( Text2, Text2Colour );
		}
		
		/// <summary>
		/// Gets the colour for all the text.
		/// </summary>
		[ Test ]
		public void EntireStringColour( )
		{
			Assert.AreEqual( Color.Empty, FormattedText.GetColour( 0, Text1.Length + Text2.Length ), "Entire string colour is wrong." );
		}
		
		/// <summary>
		/// Gets the colour the middle of the text.
		/// </summary>
		[ Test ]
		public void MiddleTextColour( )
		{
			Assert.AreEqual( Color.Empty, FormattedText.GetColour( Text1.Length - 1, 2 ), "Middle string colour is wrong." );
		}		
		
		/// <summary>
		/// Gets the colour for the start of the text.
		/// </summary>
		[ Test ]
		public void StartOfStringColour( )
		{
			Assert.AreEqual( Text1Colour, FormattedText.GetColour( 0, Text1.Length ), "Start of text is wrong colour." );
		}		
		
		/// <summary>
		/// Gets the colour for the start of the text.
		/// </summary>
		[ Test ]
		public void EndOfStringColour( )
		{
			Assert.AreEqual( Text2Colour, FormattedText.GetColour( Text1.Length, Text2.Length ), "End of text is wrong colour." );
		}			
	}
}
